namespace Asmex.FileViewer
{
    using System;
    using System.Collections;
    using System.IO;

    public class Relocations : Region
    {
        private RelocationBlock[] _blox;

        public Relocations(BinaryReader reader, MModule mod)
        {
            if (mod.ModHeaders.OSHeaders.PEHeader.DataDirs[5].Rva != 0)
            {
                uint num = mod.ModHeaders.Rva2Offset(mod.ModHeaders.OSHeaders.PEHeader.DataDirs[5].Rva);
                uint num2 = num + mod.ModHeaders.OSHeaders.PEHeader.DataDirs[5].Size;
                base.Start = num;
                base.Length = num2 - num;
                reader.BaseStream.Position = num;
                ArrayList list = new ArrayList();
                while (reader.BaseStream.Position < num2)
                {
                    RelocationBlock block = new RelocationBlock(reader);
                    list.Add(block);
                }
                this._blox = (RelocationBlock[]) list.ToArray(typeof(RelocationBlock));
            }
        }

        public RelocationBlock[] Blocks
        {
            get
            {
                return this._blox;
            }
        }
    }
}
